<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <script src="__PUBLIC__/js/jquery-1.9.0.js"></script>
    <script src="__PUBLIC__/js/angular.js"></script>
    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.css">
    <!--App自定义的css-->
    <link rel="stylesheet" href="__PUBLIC__/css/app.css">
    <link rel="stylesheet" href="__PUBLIC__/css/cart.css">
    <script src="__PUBLIC__/common.js"></script>
    <style>
        .enter{
            background: url("__PUBLIC__/images/enter-right.png")no-repeat right center;
            background-size: auto 50%;
        }
        .address{
            margin-top: 5px;
        }
        .cart .mui-input-row {
            height: 42px;
        }
        .cart .mui-checkbox input[type='checkbox']:before {
            line-height: 42px;
        }
    </style>
</head>
<body ng-app="myApp" ng-controller="Ctrl" ng-cloak>
<!--header-->
<header class="mui-bar mui-bar-nav" >
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"style="color: white" ></a>
    <h1 class="mui-title">附近代理商</h1>
</header>
<div class="mui-content cart">
    <ul class="mui-table-view address">
        <li class="mui-table-view-cell mui-media cart-goods" ng-repeat="ag in agen">
            <div class="mui-media-body" style="width: 80%;float: left" ng-click="select(ag.agenno)">
                <span style="width: 90%">{{ag.name_path}}</span>
                <span style="width: 90%">{{ag.levelname}}代理<label style="margin-left: 3em">{{ag.name}}</label></span>
            </div>
            <div class="mui-media-body" style="width: 20%;float: left;padding-left:0">
                <p style="line-height: 42px;text-align: right"><cite ng-show="{{ag.juli<1000}}">{{ag.juli}}m</cite><cite ng-show="{{ag.juli>1000}}">{{((ag.juli)/1000).toFixed(1)}}km</cite></p>
            </div>
        </li>
    </ul>
</div>

<div style="height: 100px">
</div>
<include file="./Application/Home/View/pub/foot.html" name="m"/>
<script>
    function show(){
        var position  = {};
        var arrCookie = document.cookie.split(';');
        for (var name in arrCookie){
            var temp= arrCookie[name].split("=");
            position[temp[0].trim()] = temp[1]
        }
       return position;
    }
    var arr=show();

    var app = angular.module('myApp', []);
    app.controller('Ctrl', function($scope,$http) {
        $http({
            method:'POST',
            data:arr,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
            transformRequest: function(obj) {
                var str = [];
                for (var p in obj) {
                    str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                }
                return str.join("&");
            },
            url: "/index.php/Home/Index/nearbyagent"
        }).then(function successCallback(response) {
            if(response.data.code==-1){
                layer.msg(response.data.msg,{time:2000})
            } else if(response.data.code==0){
                $scope.agen = response.data.data;
            }
        }, function errorCallback(response) {
        });

        $scope.select=function (agenno) {
            window.location.href="/index.php/Home/Index/register?id="+agenno;
        }
    })

</script>


</body>

<script src="__PUBLIC__/mui/js/mui.min.js"></script>
</html>